export function maskAndTrimStr (str) {
  const sensitiveWords = ['妈的', '脏话']
  const pattern = new RegExp(sensitiveWords.map(w => `[${w}]`).join('|'), 'gi')
  const trimmedStr = str.replace(/\s+/g, ' ').trim() // 去除额外的空白符并调整字符串
  return trimmedStr.replace(pattern, match => '*'.repeat(match.length))
}

// const inputStr = '他妈妈的衣服  不太行，但是我也不好意思说什么'

// console.log(maskAndTrimStr(inputStr, sensitiveWords))
